home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C / Frameworks / TransSkel 3.24 / Source / Positioning Stuff / SkelGetRefRect.c < prev    next >
Text File  |  1996-01-17  |  2KB  |  60 lines

  1. /*
  2.  * Get a reference rectangle for window positioning.
  3.  *
  4.  * Reference rect for position types:
  5.  *    skelPositionNone -- no reference rect
  6.  *    skelPositionOnMainDevice -- usable area on main device
  7.  *    skelPositionOnParentWindow -- content rect of frontmost visible window
  8.  *    skelPositionOnParentDevice -- usable area on screen of frontmost visible window
  9.  *
  10.  * If there's no frontmost window, positions that use it default to
  11.  * skelPositionOnMainDevice.
  12.  *
  13.  * Result for position skelPositionNone is same as for skelPositionOnMainDevice
  14.  * just so that result isn't undefined, but caller would be better off to handle
  15.  * skelPositionNone case itself.
  16.  *
  17.  * 18 Feb 94
  18.  * - Return structure rect rather than content rect of parent window when
  19.  * position type is skelPositionOnParentWindow.
  20.  */
  21.  
  22. # include    "TransSkel.h"
  23.  
  24.  
  25. pascal void
  26. SkelGetReferenceRect (Rect *r, short positionType)
  27. {
  28. WindowPtr    frontWind;
  29.  
  30.     /*
  31.      * Assume default positioning will be with reference to main device.
  32.      * This will also be used as the fallback for positionings that use
  33.      * FrontWindow() if FrontWindow() is nil.
  34.      */
  35.  
  36.     SkelGetMainDeviceRect (r);
  37.  
  38.     if (positionType == skelPositionNone)    /* leave window as is */
  39.         return;
  40.  
  41.     /*
  42.      * Find frontmost visible window
  43.      */
  44.     frontWind = FrontWindow ();
  45.     while (frontWind != (WindowPtr) nil && !((WindowPeek) frontWind)->visible)
  46.         frontWind = (WindowPtr) ((WindowPeek) frontWind)->nextWindow;
  47.  
  48.     switch (positionType)
  49.     {
  50.     case skelPositionOnParentWindow:
  51.         if (frontWind != (WindowPtr) nil)
  52.             SkelGetWindStructureRect (frontWind, r);
  53.         break;
  54.     case skelPositionOnParentDevice:
  55.         if (frontWind != (WindowPtr) nil)
  56.             (void) SkelGetWindowDevice (frontWind, (GDHandle *) nil, r);
  57.         break;
  58.     }
  59. }
  60.